﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace undeadtank
{
    class Menu
    {
        Texture2D textura; 
        public int selecao;
        int limite;
        int posY;
        int distY;
        int alignX;
        List<String> opcao = new List<string>();

        public void Inicializar(Texture2D textura, int limite, int posY, int distY, int alignX, String[] texto)
        {
            this.textura = textura;
            this.limite = limite;
            this.posY = posY;
            this.distY = distY;
            this.alignX = alignX;
            selecao = 0;
            this.opcao.Clear();
            for (int i = 0; i < limite; i++)
            {
                this.opcao.Add(texto[i]);
            }
        }

        public void Atualizar()
        {
            if (selecao >= limite) { selecao = 0; }
            else if (selecao < 0) { selecao = limite - 1; }
        }

        public void Desenhar(SpriteBatch spriteBatch, SpriteFont fonte)
        {
            spriteBatch.Draw(textura, Vector2.Zero, Color.White);
            for (int i = 0; i < limite; i++)
            {
                if (i == selecao)
                {
                    spriteBatch.DrawString(fonte, opcao[i], new Vector2(alignX, (posY + i * distY)), Color.Red);
                }
                else
                {
                    spriteBatch.DrawString(fonte, opcao[i], new Vector2(alignX, (posY + i * distY)), Color.White);
                }
            }
        }
    }
}